package org.service;

import java.util.ArrayList;

import org.dao.ProductDao;
import org.model.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service(value = "productService")
public class ProductService {
	@Autowired
	private ProductDao productDao;
	
	public ArrayList<Product> findNewestProduct(int count){
		return productDao.getMoreProduct(0,count);
	}
	
	public Product findProduct(int productId){
		return productDao.findProduct(productId);
	}

	public ArrayList<Product>  pageProducts(Integer classId, Integer page,
			Integer productInPage) {
		return productDao.getMoreProduct(classId, (page-1)*productInPage, productInPage);
	}

	public Integer productClassProductCount(Integer classId) {
		return productDao.getProductClassProductCount(classId);
	}
}
